<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductOrdersTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('product_orders', function (Blueprint $table) {
            $table->id();
            $table->string('order_no')->unique()->comment('订单编号');
            $table->unsignedBigInteger('user_id')->comment('用户ID');
            $table->unsignedBigInteger('product_id')->comment('产品ID');
            $table->tinyInteger('type')->default(1)->comment('1-普通订单,2-复购订单');
            $table->decimal('total_amount', 10, 2)->comment('订单总金额');
            $table->decimal('price', 10, 2)->comment('购买时单价');
            $table->integer('number')->comment('购买数量');
            $table->tinyInteger('status')->default(1)->comment('1-待付款,2-已付款,3-待发货,4-已发货');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `product_orders` comment '产品订单'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('product_orders');
    }
}
